package cl.AnotacionesSOAWS;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;

import android.widget.EditText;


public class AlumnoSOAWS {
	private static String METHOD_NAME ;
	private static String NAMESPACE ;
	private static String URL;
	
	public void coneccionws(){
		
		
		NAMESPACE = "http://ws"; 
		URL = "http://londres.ceisufro.cl:8080/EQUIPO5_PDS_V2/services/AlumnoSOA?wsdl";
	}

	
	public String getByNombre(){


            coneccionws();

            METHOD_NAME = "getByNombre";

            String SOAP_ACTION = NAMESPACE + METHOD_NAME;

            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
         //   PropertyInfo getByNombre = new PropertyInfo();


           // request.addProperty(getByNombre);

            SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
                            SoapEnvelope.VER11);
            soapEnvelope.dotNet = true;
            soapEnvelope.implicitTypes = true;
            soapEnvelope.setOutputSoapObject(request);

            AndroidHttpTransport aht = new AndroidHttpTransport(URL);

            String datosJsonString;
            try {
                    aht.call(SOAP_ACTION, soapEnvelope);
                    SoapPrimitive resultString = (SoapPrimitive) soapEnvelope
                                    .getResponse();
                    datosJsonString = resultString.toString();
                    return datosJsonString;
            } catch (Exception e) {
                    e.printStackTrace();
                    // en caso de no tener acceso al web service
                    datosJsonString = "Error Conexion";
                    
            }
            return datosJsonString;
    	}	
	}

